import { IconBtn } from "./iconTabBar/IconBtn";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../../resource/ImagesConst";
import { IconTabBar } from "./iconTabBar/IconTabBar";
import { GScrollPane } from "../../../../../com/mui/controls/GScrollPane";
import { ScrollPolicy } from "../../../../../fl/controls/ScrollPolicy";
import { OpenServerDetailPanel } from "./OpenServerDetailPanel";
import { Cache } from "../../../cache/Cache";
import { DailySpecialInfo } from "../../../model/DailySpecialInfo";
import { EffectManager } from "../../../manager/EffectManager";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
type int = number;
//class OpenServerActList
    
    export  class OpenServerActList /* flash.display.Sprite */
    {
        constructor(arg1: int, arg2: int)
        {
            
            this._width = arg1;
            this._height = arg2;
            this.initUI();
            return;
        }

        /* internal  */onTabBarClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.target as IconBtn;
            if (loc1 && loc1.info) 
            {
                this.activeDetailReq();
            }
            return;
        }

        /* internal  */activeDetailReq(): void
        {
            var loc1=this._tabBar.lastSelected as IconBtn;
            if (loc1 && loc1.info) 
            {
                this._newDetailPanel.dispose(false);
                Dispatcher.dispatchEvent(new DataEvent(EventName.DailySpecialDetailInfoReq, loc1.info.code));
            }
            return;
        }

        protected initUI(): void
        {
            this._tabBarBg = ResouceConst.getScaleBitmap(ImagesConst.WindowCenterB);
            this._tabBarBg.width = 197;
            this._tabBarBg.height = 400;
            addChild(this._tabBarBg);
            this._tabBar = new IconTabBar(IconBtn, 197, 396);
            this._tabBar.addEventListener(flash.events.MouseEvent.CLICK, this.onTabBarClickHandler);
            addChild(this._tabBar);
            this._scrollPane = new GScrollPane();
            this._scrollPane.x = 0;
            this._scrollPane.y = 2;
            this._scrollPane.width = 197;
            this._scrollPane.height = 396;
            this._scrollPane.styleName = "GScrollPane";
            this._scrollPane.verticalScrollPolicy = ScrollPolicy.AUTO;
            this._scrollPane.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._scrollPane.source = this._tabBar;
            this._scrollPane.scrollDrag = false;
            this._scrollPane.focusEnabled = false;
            addChild(this._scrollPane);
            this._newDetailPanel = new OpenServerDetailPanel();
            this._newDetailPanel.x = this._tabBar.x + this._tabBar.width + 4;
            this._newDetailPanel.y = this._tabBar.y;
            addChild(this._newDetailPanel);
            return;
        }

        public updateData(arg1: Array<any>): void
        {
            this.dispose();
            this._tabBar.updateData(arg1);
            if (!Cache.instance.loginNotice.isOldAct) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.OpenSeverGoShineTabBar, Cache.instance.loginNotice.shineCodeList));
            }
            this._scrollPane.refreshPane();
            this._scrollPane.update();
            this._scrollPane.verticalScrollPosition = 0;
            this._tabBar.selectedByIndex(0);
            this.activeDetailReq();
            return;
        }

        public updateActiveDetailInfo(arg1: DailySpecialInfo): void
        {
            if (this._tabBar.lastSelected && this._tabBar.lastSelected.info && this._tabBar.lastSelected.info.code == arg1.code) 
            {
                this._newDetailPanel.updateData(arg1);
            }
            return;
        }

        public onGetRewardRes(arg1: int, arg2: int): void
        {
            this._newDetailPanel.onGetRewardRes(arg1, arg2);
            return;
        }

        public onActiveConditionUpdate(arg1: Array<any>): void
        {
            this._newDetailPanel.onActiveConditionUpdate(arg1);
            return;
        }

        public updataGetRewardState(arg1: int, arg2: Array<any>): void
        {
            if (this._tabBar.lastSelected && this._tabBar.lastSelected.info && this._tabBar.lastSelected.info.code == arg1) 
            {
                this._newDetailPanel.updataGetRewardState(arg2);
            }
            return;
        }

        public openActiveBtnShineOrNot(arg1: int, arg2: Boolean): void
        {
            if (this._tabBar && this._tabBar.getByIndex(arg1)) 
            {
                if (arg2) 
                {
                    EffectManager.glowFilterReg(this._tabBar.getByIndex(arg1), [FilterConst.guideTipsFilter]);
                }
                else 
                {
                    EffectManager.glowFilterUnReg(this._tabBar.getByIndex(arg1));
                }
            }
            return;
        }

        public jumpTabBar(arg1: int): void
        {
            if (this._tabBar) 
            {
                this._scrollPane.refreshPane();
                this._scrollPane.update();
                this._scrollPane.verticalScrollPosition = arg1 * 50;
                this._tabBar.selectedByIndex(arg1);
                this.activeDetailReq();
            }
            return;
        }

        public dispose(): void
        {
            this._newDetailPanel.dispose();
            return;
        }

        /* internal */ /* var */_tabBarBg: ScaleBitmap;

        /* internal */ /* var */_tabBar: IconTabBar;

        /* internal */ /* var */_scrollPane: GScrollPane;

        /* internal */ /* var */_newDetailPanel: OpenServerDetailPanel;

        /* internal */ /* var */_width: int;

        /* internal */ /* var */_height: int;
    }
